<?php

namespace SinoPHP\BbdBoss\Model;

use Upfor\UpforPHP\Model;

class VirtualNode extends Model {

    /**
     * 获取虚拟节点列表
     *
     * @param string $fields
     * @param array  $where
     * @param null   $limit
     * @param null   $offset
     * @return array
     */
    public function getVirtualNodeList($fields = '*', $where = array(), $limit = null, $offset = null) {

        $this->db->table('virtual_node', 'V');
        $this->db->field($fields);
        $this->db->join(['physical_node', 'N'], ['N.physical_node_id' => 'V.physical_node_id']);
        $this->db->join(['server_ip', 'S'], ['S.ip_id' => 'V.server_ip_id']);
        $this->db->where($where);
        $this->db->limit($limit, $offset);
        $this->db->order('virtual_node_id DESC');
        $data = $this->db->getList();

        return $data;
    }

}
